using MediatR;
using RBAC.ErrorCode;
using System.Collections.Generic;

namespace RBAC.Write.Api.Application.Command.Approval
{
    /// <summary>
    /// 创建审批流程命令（支持同时创建审批节点）
    /// </summary>
    public class CreateApprovalProcessCommand : IRequest<APIResult<long>>
    {
        /// <summary>
        /// 流程名称
        /// </summary>
        public string ProcessName { get; set; } = string.Empty;

        /// <summary>
        /// 流程描述
        /// </summary>
        public string Description { get; set; } = string.Empty;

        /// <summary>
        /// 启用状态（0:禁用 1:启用）
        /// </summary>
        public int Status { get; set; } = 1;

        /// <summary>
        /// 流程类型（例如：采购订单/销售订单/入库单/出库单等）
        /// </summary>
        public string ProcessType { get; set; } = string.Empty;

        /// <summary>
        /// 业务类型（前端传入，当前实体未持久化该字段，可用于后续扩展）
        /// </summary>
        public int? BusinessType { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string? CreateUser { get; set; }

        /// <summary>
        /// 需要一并创建的审批节点集合
        /// </summary>
        public List<CreateApprovalNodeDto> Nodes { get; set; } = new();
    }

    /// <summary>
    /// 创建审批节点DTO
    /// </summary>
    public class CreateApprovalNodeDto
    {
        /// <summary>
        /// 节点名称
        /// </summary>
        public string NodeName { get; set; } = string.Empty;
        /// <summary>
        /// 审批人ID（字符串输入，将在服务端转换为long）
        /// </summary>
        public string ApproverId { get; set; } = string.Empty;
        /// <summary>
        /// 审批人姓名
        /// </summary>
        public string ApproverName { get; set; } = string.Empty;
        /// <summary>
        /// 审批方式 (1:依次审批 2:会签审批 3:或签审批)
        /// </summary>
        public int ApprovalType { get; set; } = 1;
        /// <summary>
        /// 节点顺序
        /// </summary>
        public int NodeOrder { get; set; }
    }
}
